<template>
    <!-- <div>
     
    </div> -->

<el-container class="home">
 
    <!-- 头部 -->
  <el-header class="home-header">Header<el-button type="info" @click="logout">
         退出
       </el-button>
       </el-header>
  <el-container>
    <el-aside width="200px">Aside</el-aside>
    <el-main>Main
       <img style="width:111px; height:111px" src="http://ting.fensi.work/uploads/fe1a0fda27f68ac3ef9ea6d8dd6a3084" alt="">
<el-upload
  class="upload-demo"
  ref="upload"
  action="http://ting.fensi.work/api/admin/upload"
  :on-preview="handlePreview"
  :on-remove="handleRemove"
  :headers="headers"
  :on-success="handleAvatarSuccess"
  :auto-upload="false">
  <el-button slot="trigger" size="small" type="primary">选取文件</el-button>
  <el-button style="margin-left: 10px;" size="small" type="success" @click="submitUpload">上传到服务器</el-button>
  <div slot="tip" class="el-upload__tip">只能上传jpg/png文件，且不超过500kb</div>
</el-upload>
    </el-main>
  </el-container>
</el-container>
</template>
<script>
export default {
    data () {
      return {
       fileList: [{name: 'food.jpeg', url:'/upload'}],
      };
    },
    methods:{
        logout(){
        window.localStorage.clear();
        this.$router.push("/login");
        //清理token
        },
              submitUpload() {
        this.$refs.upload.submit();
      },
      handleRemove(file, fileList) {
        // console.log(file, fileList);
      },
      handlePreview(file) {
        
      },
      handleAvatarSuccess(res,file ) {
          console.log( '=====', file);
      }
    },

computed: {
    headers() {
      return {
        authorization: "base eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjVmMDcyNDI3MTMwY2EyMWMzODc4YjQzOCIsImlhdCI6MTU5NDM4OTAxOH0._DAyPhGa1a_gN4vG4hgUiqF2FBz08B86dM9V1CvitAM" 
      };
    }
  }
}
</script>
<style lang="less" scoped>
    .home {
    height: 100%;
  }
  .home-header {
    background-color: #373D41;
    display: flex;
    justify-content: space-between;
    color: #eee;
    padding-left: 0;
    align-items: center;
    font-size: 25px;
    > div {
      display: flex;
      align-items: center;
      span {
        margin-left: 10px;
      }
    }
  }
  .el-aside {
    background-color: #333744;
  }
  .el-main {
    background-color: #EAEDF1;
  }
  .iconfont {
    margin-right: 10px;
  }
  .el-menu {
    border-right: 0 ;
  }
  .aside-button {
    background-color: #4A5064;
    text-align: center;
    line-height: 24px;
    color: white;
    font-size: 10px;
    letter-spacing: 0.2em;
    cursor: pointer;
  }
</style>